var __extends =
    (this && this.__extends) ||
    (function () {
      var t = function (e, n) {
        return (t =
          Object.setPrototypeOf ||
          ({ __proto__: [] } instanceof Array &&
            function (t, e) {
              t.__proto__ = e;
            }) ||
          function (t, e) {
            for (var n in e)
              Object.prototype.hasOwnProperty.call(e, n) && (t[n] = e[n]);
          })(e, n);
      };
      return function (e, n) {
        function i() {
          this.constructor = e;
        }
        if ("function" != typeof n && null !== n)
          throw new TypeError(
            "Class extends value " + String(n) + " is not a constructor or null"
          );
        t(e, n),
          (e.prototype =
            null === n
              ? Object.create(n)
              : ((i.prototype = n.prototype), new i()));
      };
    })(),
  CommonActivityView = (function (t) {
    function e() {
      var e = t.call(this) || this;
      return (
        e.btn_back.on(Laya.Event.CLICK, e, e.onCancleFn),
        e.btn_ok.on(Laya.Event.CLICK, e, e.onOkFn),
        WebSocketService.addListener({
          caller: e,
          code: 8e3,
          method: e.onLoadData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 8001,
          method: e.onLoadData,
        }),
        WebSocketService.addListener({
          caller: e,
          code: 46061,
          method: e.onLoadData,
        }),
        e
      );
    }
    return (
      __extends(e, t),
      (e.open = function (t) {
        null == this.instance && (this.instance = new e()),
          (this.instance.npcId = t);
        var n = CommonActivityNpcInit[t];
        (this.instance.label_state.text = ""),
          (this.instance.label_time.text = ""),
          WebSocketService.send(n.initReq);
      }),
      (e.prototype.onLoadData = function (t) {
        if (0 == t.code) {
          if ((t.msg && ToastView.toastView(t.msg), t.data)) {
            var e = CommonActivityNpcInit[this.npcId];
            if (e) {
              t.msg && this.refreshStatus(e.refresh);
              var n = t.data;
              (this.data = n),
                0 == n.ok
                  ? (this.btn_ok.visible = !1)
                  : (this.btn_ok.visible = !0),
                n.title
                  ? (this.label_title.text = n.title)
                  : (this.label_title.text = e.title),
                n.e
                  ? (this.label_content.text = n.e)
                  : (this.label_content.text = e.content),
                n.m && (this.label_state.text = n.m);
              var i = "";
              0 == t.data.s
                ? (i =
                    t.data.t > 0
                      ? "距离开始还有" + Utils.timeString(t.data.t, !1)
                      : "活动已结束")
                : t.data.t > 0 &&
                  (i = "距离结束还有" + Utils.timeString(t.data.t)),
                (this.label_time.text = i);
              for (
                var a = e.list, o = t.data.list, s = [], r = 0;
                r < o.length;
                r++
              ) {
                var c = { label_k: a[r], label_v: { text: o[r] } };
                s.push(c);
              }
              (this.list_kv.array = s),
                this.pos(0, 40),
                Laya.stage.addChild(this);
            }
          }
        } else ToastView.toastView(t.msg);
      }),
      (e.isThisNpc = function (t) {
        return !!CommonActivityNpcInit[t];
      }),
      (e.prototype.onOkFn = function () {
        var t = CommonActivityNpcInit[this.npcId];
        this.data && this.data.ok > 0 && (t.againReq.d.p1 = this.data.ok),
          WebSocketService.send(t.againReq);
      }),
      (e.prototype.onCancleFn = function () {
        this.removeSelf();
      }),
      (e.prototype.refreshStatus = function (t) {
        t && Laya.stage.event("GameMainView", t);
      }),
      e
    );
  })(ui.common.CommonPageUI);
